script_enemy_main{

let type=GetArgument;
let angle=rand(0,360);
let color=rand_int(1,10);
let fade=254;

let usespell=0;
let frame=rand_int(-5,-20);
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let GRfamiliar=("\script\Images\OtherEffects\SpellCircle1b.png");

@Initialize{
	LoadGraphic("\script\Images\OtherEffects\SpellCircle1b.png");

	SetScore(1);
	SetLife(1);

	if(type==1){ SetAngle(rand(180,120)); }
	if(type==2){ SetAngle(rand(0,60)); }
	SetSpeed(rand(1.5,1.75));
}
	
@MainLoop{

if(GetX<=minx-32 || GetX>=maxx+32 || GetY<=miny-32 || GetY>=maxy+32 && frame>=60){ VanishEnemy; }

if((GetX>minx && GetX<maxx) && (GetY>miny && GetY<maxy)){


if(GetCommonData("Difficulty")==1){
	if(frame>=0 && frame<16 && frame%2==0 && OnBomb==false){
		loop(20){
		CreateShot02(GetX,GetY,1,angle,0.035,10,70+color,0);
		angle+=360/20;
		}
	color+=1;
	if(color>10){ color=1; }
	}
} //Easy

//================================================================================================

if(GetCommonData("Difficulty")==2){
	if(frame>=0 && frame<16 && frame%2==0 && OnBomb==false){
		loop(24){
		CreateShot02(GetX,GetY,1,angle,0.04,10,70+color,0);
		angle+=360/24;
		}
	color+=1;
	if(color>10){ color=1; }
	}
} //Normal

//================================================================================================

if(GetCommonData("Difficulty")==3){
	if(frame>=0 && frame<16 && frame%2==0 && OnBomb==false){
		loop(28){
		CreateShot02(GetX,GetY,1,angle,0.045,10,70+color,0);
		angle+=360/28;
		}
	color+=1;
	if(color>10){ color=1; }
	}
} //Hard

//================================================================================================

if(GetCommonData("Difficulty")==4){
	if(frame>=0 && frame<16 && frame%2==0 && OnBomb==false){
		loop(32){
		CreateShot02(GetX,GetY,1,angle,0.05,10,70+color,0);
		angle+=360/32;
		}
	color+=1;
	if(color>10){ color=1; }
	}
} //Lunatic
} //Onscreen

if(fade>0 && frame>=0){ fade-=2; }
if(fade<=0){ VanishEnemy; }


time++;
frame++;

}

@DrawLoop{
	SetGraphicScale(0.2,0.2);
	SetTexture(GRfamiliar);
	SetGraphicAngle(0,0,time*2);
	SetColor(fade,0,fade);
	SetRenderState(ADD);
	SetAlpha(100);
	SetGraphicRect(0,0,200,200);
	DrawGraphic(GetX,GetY);
}

@Finalize{
}

}